#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "manage.h"
#include "common.h"

void tips(); // 提示词
void menu(); // 菜单

int main(int argc,char * argv[]){
	BookList * bookList;
	bookList=Init_BookList();
	tips();
	char chose;
	while(true){
		menu();
		chose = getchar();
		clear_screen();
		if(clear_buffer()){
			fprintf(stderr,"请不要输入多余内容\n");
			continue;
		}
		switch (chose) {
			case '0':
				Save_BookList(bookList);  // 保存信息
				Destroy_BookList(bookList);
				exit(0);
			case '1':
				Add_Book(bookList);
				break;
			case '2':
				Brrow_Book(bookList);
				break;
			case '3':
				List_Book(bookList);
				break;
			case '4':
				Return_Book(bookList);
				break;
			default:
				fprintf(stderr,"未找到对应的选项，请重新输入\n");
				break;
		}
	}
}

void tips(){
	printf("\t+-------------------------------+\n");
	printf("\t|          图书管理系统         |\n");
}

void menu(){
	printf("\t+===============================+\n");
	printf("\t|  0) 退出程序                  |\n");
	printf("\t|  1) 新增书籍入库              |\n");
	printf("\t|  2) 书籍借阅                  |\n");
	printf("\t|  3) 书籍列表                  |\n");
	printf("\t|  4) 归还书籍                  |\n");
	printf("\t+===============================+\n");
}

